import request from '@/utils/request'
// import qs from 'qs'

// 连接查看

// 删除查询列表
export function delArray (params) {
  var data = fromData(params)
  return request({
    url: '/connection/delArray',
    method: 'post',
    data
  })
}

// 清空连接
export function clearArray (params) {
  var data = fromData(params)
  return request({
    url: '/connection/clearArray',
    method: 'post',
    data
  })
}

// 获取查询列表
export function getArray (params) {
  var data = fromData(params)
  return request({
    url: '/connection/getArray',
    method: 'post',
    data
  })
}

// 获取当前总连接数
export function getAllCount (params) {
  var data = fromData(params)
  return request({
    url: '/connection/getAllCount',
    method: 'post',
    data
  })
}

// function fromData (params) {
//   var data = qs.stringify(params)
//   return data
// }

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
